﻿package frEngine.animateControler.colorControler
{
    import baseEngine.core.*;
    import flash.events.*;
    import frEngine.*;
    import frEngine.animateControler.*;
    import frEngine.animateControler.keyframe.*;
    import frEngine.event.*;
    import frEngine.shader.*;
    import frEngine.shader.registType.*;

    public class RimLightStrengthController extends MeshAnimateBase
    {
        public var register:FcParam;
        private var _targetmaterialParams:MaterialParams;

        public function RimLightStrengthController()
        {
            return;
        }// end function

        override public function get type() : int
        {
            return AnimateControlerType.RimLightStrengthController;
        }// end function

        override protected function getBaseValue(param1:Pivot3D) : Object
        {
            return Mesh3D(param1).material.materialParams.rimLightStrengthBase;
        }// end function

        override protected function setSurfaceHander(event:Event) : void
        {
            super.setSurfaceHander(event);
            this.reBuilderHander(null);
            FrEventDispatcher.instance.proxyAddEventListener(targetMesh.material, Engine3dEventName.MATERIAL_REBUILDER, this.reBuilderHander);
            return;
        }// end function

        private function reBuilderHander(event:Event) : void
        {
            if (targetMesh)
            {
                this.register = targetMesh.material.getParam("{RimParams}", false);
                this._targetmaterialParams = targetMesh.material.materialParams;
            }
            return;
        }// end function

        override protected function setTargetProperty(param1) : void
        {
            var _loc_2:* = Number(param1);
            if (this.register)
            {
                changeBaseValue(null, this._targetmaterialParams.rimLightStrengthBase);
                this.register.value[1] = _loc_2;
            }
            return;
        }// end function

        override public function dispose(param1:Boolean = true) : void
        {
            FrEventDispatcher.instance.proxyRemoveEventListener(targetMesh.material, Engine3dEventName.MATERIAL_REBUILDER, this.reBuilderHander);
            super.dispose();
            if (this.register)
            {
                this.register.value[1] = this._targetmaterialParams.rimLightStrengthBase;
            }
            return;
        }// end function

    }
}
